package com.app.orderservicesample;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import com.netflix.loadbalancer.RoundRobinRule;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @Author: 伴你时光尽头
 * @Date: 2019/11/7 19:26
 */
@Configuration
public class Config {
    @Bean
    @LoadBalanced //启用服务消费者的负载均衡（简单点说，当服务调用者有n个的时候，消费者可以轮询这些调用者）
    RestTemplate restTemplate() {
        return new RestTemplate();
    }

    @Bean
    public IRule rule() {

        return new RoundRobinRule();
    }


}
